//
//  THAddressHomeTableViewCell.m
//  TreeHole
//
//  Created by apple on 2020/9/7.
//  Copyright © 2020 stoneobs. All rights reserved.
//

#import "THAddressHomeTableViewCell.h"

@interface THAddressHomeTableViewCell()
@property(nonatomic, strong) STLabel                     *titleLable;/**<  */
@property(nonatomic, strong) STLabel                     *desLable;/**<  */
@property(nonatomic, strong) STButton                     *defultButton;/**<  */
@property(nonatomic, strong) UIView                     *white_view;/**<  */
@end
@implementation THAddressHomeTableViewCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    if (self == [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        [self stoneobs_ui_configSubView];
    }
    return self;
}
+ (CGFloat)stoneobs_ui_cell_height{
    return 80;
}
#pragma mark --configSubView
- (void)stoneobs_ui_configSubView{
    self.selectionStyle = UITableViewCellSelectionStyleNone;
    self.backgroundColor = UIColor.clearColor;
    
    UIView * white_view = [[UIView alloc] initWithFrame:CGRectMake(15, 0, UISCREEN_WIDTH - 30, self.class.stoneobs_ui_cell_height - 10)];
    white_view.layer.cornerRadius = 4;
    white_view.backgroundColor = UIColor.whiteColor;
    [self.contentView addSubview:white_view];
    
    
    STLabel * stoneobs_ui_label = [[STLabel alloc] initWithFrame:CGRectMake(10, 15, white_view.width - 65, 20)
                                                            text:@"杜卡迪雷克萨；kd"
                                                       textColor:STONEOBS_UI_FIRST_TEXT_COLOR
                                                            font:12
                                                     isSizetoFit:NO
                                                   textAlignment:NSTextAlignmentLeft];
    [white_view addSubview:stoneobs_ui_label];
    self.titleLable = stoneobs_ui_label;
    STButton * stoneobs_ui_button = [[STButton alloc] initWithFrame:CGRectMake(0, 0, 33, 16)
                                                              title:@"默认"
                                                         titleColor:UIColor.whiteColor
                                                          titleFont:8
                                                       cornerRadius:4
                                                    backgroundColor:WH_UICOLOR_FROM_RGBA(0xFB692A)
                                                    backgroundImage:nil
                                                              image:nil];
    
    [white_view addSubview:stoneobs_ui_button];
    stoneobs_ui_button.contentHorizontalAlignment = UIControlContentHorizontalAlignmentCenter;
    stoneobs_ui_button.centerY = stoneobs_ui_label.centerY;
    self.defultButton = stoneobs_ui_button;
    
    STLabel * stoneobs_ui_des_label = [[STLabel alloc] initWithFrame:CGRectMake(10, 15, white_view.width - 65, 20)
                                                            text:@"收货人地区 收货人详细地址收货人详细地址"
                                                       textColor:STONEOBS_UI_FIRST_TEXT_COLOR
                                                            font:12
                                                     isSizetoFit:NO
                                                   textAlignment:NSTextAlignmentLeft];
    [white_view addSubview:stoneobs_ui_des_label];
    stoneobs_ui_des_label.bottom = white_view.height - 15;
    self.desLable = stoneobs_ui_des_label;
    
    
    STLabel * stoneobs_ui_edit_label = [[STLabel alloc] initWithFrame:CGRectMake(10, 0, 64, white_view.height)
                                                            text:@"编辑"
                                                       textColor:STONEOBS_UI_THIRD_TEXT_COLOR
                                                            font:12
                                                     isSizetoFit:NO
                                                   textAlignment:NSTextAlignmentCenter];
    [white_view addSubview:stoneobs_ui_edit_label];
    stoneobs_ui_edit_label.right = white_view.width;
    
    
    UIView * stoneobs_ui_line = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 0.5, 20)];
    stoneobs_ui_line.backgroundColor = STONEOBS_UI_LINE_COLOR;
    [white_view addSubview:stoneobs_ui_line];
    stoneobs_ui_line.left = stoneobs_ui_edit_label.left;
    stoneobs_ui_line.centerY = white_view.height/2;
    
}
- (void)setModel:(THAddressModel *)model{
    _model = model;
    self.titleLable.text = [NSString stringWithFormat:@"%@ %@",model.name,model.phone];
    self.titleLable.attributedText = [self.titleLable.text stoneobs_fun_st_convertAttributeStringWithKeyWord:model.name attributes:@{NSFontAttributeName:[UIFont systemFontOfSize:15]}];
    [NSString stoneobs_fun_lableAutoAdjustWitdhWithLabel:self.titleLable];
    self.titleLable.width = self.titleLable.width + 20;
    self.defultButton.left = self.titleLable.right + 0;
    self.defultButton.hidden = !model.is_default;
    self.desLable.text = [NSString stringWithFormat:@"%@%@%@ %@",model.p_name,model.c_name,model.d_name,model.detail];
    
}
@end
